/**
 *
 * 4.循环数组，从数组对象里找到符合条件的对象，只有一条该对象的索引，找不到则返回-1
 */
const arr = [
  { name: "张三", id: 1 },
  { name: "李四", id: 2 },
  { name: "李四", id: 3 },
];
const id = 2;
const index = arr.findIndex((v) => v.id === id);
console.log("index", index);
//console index 1
const id2 = 4;
const index2 = arr.findIndex((v) => v.id === id2);
console.log("index2", index2);
//console index2 -1
